#!/usr/bin/python3
# -*- coding: utf-8 -*-
# @Time : 2021/9/13 9:16
# @Author : lenovo
# @Email : 26541796406@qq.com
# @File : notice_page.py
# @Project : crm
"""公告界面"""
from selenium.webdriver.common.by import By
from page.base_page import BasePage
from utils.util import HS3
class Notice(BasePage):
    """公告界面所有元素以及对应操作"""
    url = "{}/crm3/index.php?m=announcement".format(HS3)
    """定义定位器"""
    add_locator = (By.XPATH,'/html/body/div[5]/div[2]/div[1]/div[2]/a')  # 添加公告
    look_locator = (By.LINK_TEXT,'查看')  # 查看公告信息
    amend_locator = (By.LINK_TEXT,'编辑')  # 编辑公告
    del_locator = (By.LINK_TEXT,' 删除')  # 删除公告
    disable_locator = (By.LINK_TEXT,'停用')  # 停用公告
    release_locator = (By.LINK_TEXT,'发布')  # 发布公告
    all_input_locator = (By.ID,'check_all')  # 选择所有单选框
    input_locator = (By.NAME,'announcement_id[]')  # 单选框
    """具体操作"""
    def add_notice(self):
        """点击新建"""
        self.driver.find_element(*self.add_locator).click()
    def look_notice(self):
        """点击查看"""
        self.driver.find_element(*self.look_locator).click()
    def amend_notice(self):
        """点击修改"""
        self.driver.find_element(*self.amend_locator).click()
    def del_notice(self):
        """点击删除"""
        self.driver.find_element(*self.del_locator).click()
    def disable_notice(self):
        """点击停用"""
        self.driver.find_element(*self.disable_locator).click()
    def release_notice(self):
        """点击发布"""
        self.driver.find_element(*self.release_locator).click()
    def all_input(self):
        """选择全选input"""
        self.driver.find_element(*self.all_input_locator).click()
    def input1(self):
        """选择第一个单选框"""
        self.driver.find_elements(*self.input_locator)[0].click()
    def input2(self):
        """选择第一个单选框"""
        self.driver.find_elements(*self.input_locator)[1].click()
